package com.chaihu.front.service.sys.impl;

import com.alibaba.fastjson.JSONObject;
import com.chaihu.core.base.service.front.AbstractComponentService;
import com.chaihu.core.cache.MappingCache;
import com.chaihu.core.context.IPageData;
import com.chaihu.front.service.sys.SysService;
import com.chaihu.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service("sysServiceSMOImpl")
public class SysServiceServiceImpl extends AbstractComponentService implements SysService {


    @Autowired
    private RestTemplate restTemplate;

    @Override
    public ResponseEntity<String> getSysInfo(IPageData pd) {
        return businessProcess(pd);
    }

    @Override
    protected void validate(IPageData pd, JSONObject paramIn) {
    }

    @Override
    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
        String logo = MappingCache.getValue("SYS_LOGO");
        if (StringUtil.isEmpty(logo)) {
            logo = "CH";
        }
        String apiUrl = MappingCache.getValue("SYS_API_URL");

        JSONObject sysInfo = new JSONObject();
        sysInfo.put("logo", logo);
        sysInfo.put("apiUrl", apiUrl);

        return new ResponseEntity<String>(sysInfo.toJSONString(), HttpStatus.OK);
    }
}
